<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./libs/vue2.js"></script>
    <style>
        .box{
            width: 200px;
            height: 200px;
            background-color: pink;
        }
    </style>
</head>
<body>
    <div id="app">

       <home @message="messageHanlder"/>

    </div>
</body>
<script>
    Vue.component('home',{
        template:`
            <div>
                <button @click="$emit('message')">触发自定义事件</button>    
                <button @click="$off('message')">移除自定义事件</button>    
            </div>
        `
    });

    new Vue({
        el:'#app',
        methods:{
            messageHanlder(){
                alert('自定义事件被触发了');
            }
        }
    });
</script>
</html>